package com.ybkj.daijia.server.model;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;

/**
 * 地区
 *
 * @author Shine
 */
public class AreaWeight extends Base {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private String name;//地区名称

    private String memo;//收费说明

    private List<ChargeStartWeight> chargeStartWeight;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public List<ChargeStartWeight> getChargeStartWeight() {
        return chargeStartWeight;
    }

    public void setChargeStartWeight(List<ChargeStartWeight> chargeStartWeight) {
        this.chargeStartWeight = chargeStartWeight;
    }

    public void sortDistance() {
        if (CollectionUtils.isNotEmpty(chargeStartWeight)) {
            for (ChargeStartWeight cst : chargeStartWeight) {
                if (CollectionUtils.isNotEmpty(cst.getChargeWeightDistances())) {
                    Collections.sort(cst.getChargeWeightDistances(),
                        new Comparator<ChargeWeightDistance>() {
                            public int compare(ChargeWeightDistance arg0,
                                ChargeWeightDistance arg1) {
                                return arg0.getId().compareTo(arg1.getId());
                            }

                        });
                }
            }
        }
    }

    @Override
    public String toString() {
        return "Area [name=" + name + ", memo=" + memo + ", chargeStartWeight="
            + chargeStartWeight + ", id=" + id + "]";
    }


}

